package com.springboot.scheduled.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * 定时任务相关配置
 */
@Configuration
public class ScheduledConfig {

    @Value("${task.scheduler.poolSize}")
    private Integer poolSize;

    /**
     * 将 ThreadPoolTaskScheduler 添加到 Spring 容器中。
     * @return 返回实例
     */
    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        ThreadPoolTaskScheduler task = new ThreadPoolTaskScheduler();
        task.setPoolSize(poolSize);
        return task;
    }
}
